<template>
	<div>
	</div>
</template>
<script>
import {Dialog} from 'vant';
	import {
		setStore,
		getStore,
		removeStore
	} from '@/utils/storage'
	import axios from 'axios'
	import {
		baseApi,
		baseUrl,
		wechatAuthUrlFront,
		wechatAuthUrlTail,
		preLoginUrl
	} from '@/config'
	export default {
		data() {},
		computed: {},
		mounted() {
      if(!getStore('systemCode')){
        Dialog.confirm({
          message: '无法登录',
        })
          .then(() => {
          })
      }else{
        let code = this.GetQueryString('code')
        if (code !== '' && code != null && code !== undefined && code !== 'undefined') {
        	// console.log('进入loginByMp请求')
        	axios({
        		method: 'post',
        		url: baseApi + 'out2/ftms/login',
        		data: {
        			code: this.GetQueryString('code'),
              systemCode:getStore('systemCode'),
              data:getStore('data')
        		}
        	}).then((res) => {
        		// console.log(res.data,111111)
        		if (res.data.code === 0) {
        			setStore('token', res.data.token)
        			let jumpUrl = getStore('loginRequestUrl')
        			location.href = jumpUrl
        		} else {
        			location.href = baseUrl + '#/'
        		}
        	}).catch((res) => {
        		location.href = baseUrl + '#/'
        	})
        }
      }

		},
		methods: {
			GetQueryString(name) {
				var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
				var r = window.location.search.substr(1).match(reg)
				if (r != null) return unescape(r[2])
				return null
			}
		}
	}
</script>

<style scoped>

</style>
